package datastruct.stack;

import datastruct.lineList.Array;

/**
 * @author RunningShrimp
 * @date 2021/5/9  17:26
 */
public class ArrayStack<E> implements Stack<E> {
    private final Array<E> array;

    public ArrayStack(int capacity) {
        this.array = new Array<E>(capacity);
    }

    public ArrayStack() {
        this.array = new Array<E>();
    }

    @Override
    public void push(E e) {
        array.addLast(e);
    }

    @Override
    public E pop() {
        return array.removeLast();
    }

    @Override
    public E peek() {
        return array.getLast();
    }

    @Override
    public int size() {
        return array.size();
    }

    @Override
    public boolean empty() {
        return array.isEmpty();
    }
}
